package co.th.bjc.md.dbonline.control;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import co.th.bjc.md.dbonline.bean.PersonDBOnlineBean;
import co.th.bjc.md.helper.PersonHelper;
import co.th.bjc.md.model.Person;

public class PersonControl {

	private static Logger _log = Logger.getLogger(CategoryDBOnlineControl.class);
	
	public List<PersonDBOnlineBean> findAllPresident() {
		List<PersonDBOnlineBean> list = new ArrayList<PersonDBOnlineBean>(0);
		try {
			List<Person> listPerson = new PersonHelper().findPersonByPresident();
			for (Person person : listPerson) {
				list.add(setModelToBean(person));
			}
		} catch (Exception ex) {
			_log.error("Exception : " + ex.getMessage());
			ex.printStackTrace();
		}
		return list;
	}
	
	private PersonDBOnlineBean setModelToBean(Person model){
		PersonDBOnlineBean bean = new PersonDBOnlineBean();
		bean.setPersonCode(model.getPersonCode());
		bean.setPersonTitle(model.getPersonTitle());
		bean.setPersonFirstName(model.getPersonFirstName());
		bean.setPersonLastName(model.getPersonLastName());
		return bean;
	}
}
